package demo6;

import java.util.Objects;

public class Person {
    public String id;//学号 、 身份证号

    public Person(String id) {
        this.id = id;
    }

    /*@Override
    public boolean equals(Object obj) {
        if(obj == null) {
            return false;
        }
        //person1.equals(person1)
        if(this == obj) {
            return true ;
        }
        //不是同一个类型
        //person1.equals(dog)
        if(!(obj instanceof Person)) {
            return false;
        }

        Person tmp = (Person)obj;
        *//*if(tmp.id.equals(this.id)) {
            return true;
        }
        return false;*//*

        return tmp.id.equals(this.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                '}';
    }
}
